﻿<!--#Include File = "Controls\WebControl.asp"        -->
<!--#Include File = "Controls\Server_Button.asp" -->
<!--#Include File = "Controls\Server_TextBox.asp"    -->
<!--#Include File = "Controls\Server_DropDown.asp"    -->
<!--#Include File = "Controls\Server_Validation.asp"    -->
<!--#Include File = "Controls\Server_ImageList.asp"    -->
<!--#Include File = "Controls\Server_Panel.asp"   -->
<!--#Include File = "Controls\Server_CheckBox.asp" -->
<!--#Include File = "DBWrapper.asp" -->
<%
	Response.CodePage = 65001
	Response.CharSet = "utf-8"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<title>
	Bình luận
</title>
    <style type="text/css" id="mystyle">
        body{
            margin:0px; padding:1px;
        }
    </style> 
</head><body>
    



<script src="js-css/add_data/WebResource_002.js" type="text/javascript"></script>


<script src="js-css/add_data/avim.js" type="text/javascript"></script><script type="text/javascript">
    function open_help_page(){
        window.open('js-css/add_data/help.asp','help_window','toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=0, width=500, height=400, left=' + (screen.width - 500)/2 + ', top=' + (screen.height-400)/2 );
    }
</script>
<script src="js-css/add_data/WebResource.js" type="text/javascript"></script>

<%Page.Execute%>	
<%Page.OpenForm%>

        
        <div id="pnlComment">
	
            <div id="vsComment" style="color: Red; display: block;">
			<%=Request.QueryString("msg")%>
			<%mValidation%>
			</div>
            <table style="border-collapse: collapse;" width="548" align="center" border="1" cellpadding="4" cellspacing="0">
                <tbody><tr class="altRow">
                    <td>
                        Tiếng Việt:</td>
                    <td>
                        <table border="0" cellpadding="0">
		<tbody><tr>
			<td><input id="him_auto" name="viet_method" value="0" checked="checked" onclick="setMethod(0);" type="radio"><label for="him_auto">Tự động</label></td><td><input id="him_telex" name="viet_method" value="1" onclick="setMethod(1);" type="radio"><label for="him_telex">TELEX</label></td><td><input id="him_vni" name="viet_method" value="2" onclick="setMethod(2);" type="radio"><label for="him_vni">VNI</label></td><td><input id="him_viqr" name="viet_method" value="3" onclick="setMethod(3);" type="radio"><label for="him_viqr">VIQR</label></td><td><input id="him_off" name="viet_method" value="-1" onclick="setMethod(-1);" type="radio"><label for="him_off">Tắt</label></td><td><font style="font-size: 11px; color: rgb(102, 102, 102); padding-left: 10px;">[<a style="cursor: help; color: rgb(0, 0, 136);" onclick="open_help_page()" title="Giới thiệu &amp; hướng dẫn sử dụng về bộ gõ Tiếng Việt này" href="javascript:void(0);"><b>?</b></a>]</font></td>
		</tr>
	</tbody></table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Họ &amp; Tên:</td>
                    <td>
                        <%txtFullname%>
                    </td>
                </tr>
                <tr class="altRow">
                    <td>
                        Email:
                    </td>
                    <td>
                        <%txtEmail%>
                        <%chkShowEmail%><label for="chkShowEmail">Hiển thị Email cho mọi người biết</label></td>
                </tr>
                <tr class="altRow">
                    <td>
                        Tiêu đề:</td>
                    <td>
                        <%txtTitle%></td>
                </tr>
                <tr>
                    <td>
                        Nội dung:</td>
                    <td>
                        <span style="font-size: 11px; color: Gray;">Vui lòng gõ bằng tiếng Việt có dấu</span><br>
                        <%txtBody%>
                        <br>
                        <span style="font-size: 11px; color: Gray;">Tất cả bình luận của bạn đọc sẽ được Ban
                            biên tập kiểm duyệt trước khi đăng.<br>
                            Xin bạn đọc vui lòng thông cảm.</span>
                    </td>
                </tr>
                <tr class="altRow">
                    <td>
                        Xác nhận:</td>
                    <td>
                        <table>
                            <tbody><tr>
                                <td><a href="javascript:void(0)" onclick="RefreshImage('imgCaptcha')"><img id="imgCaptcha" src="controls/captcha.asp" title="Nhấn chuột vào đây để xem mã số khác" /></a>
                                    <script language="javascript">
									function RefreshImage(valImageId) {
										var objImage = document.images[valImageId];
										if (objImage == undefined) {
											return;
										}
										var now = new Date();
										objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
									}
									</script>
									</td>
                                <td><%txtCaptcha%></td>
                              
								</tr>
							</tbody>
						</table>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;
                    </td>
                    <td>
                       <%cmdSave%>
                    </td>
                </tr>
            </tbody></table>
        
</div>

<%Page.CloseForm%>


<script type="text/javascript">
    var _i,_b;
    for(_i=0; _i < radioID.length; _i++){
        _b=getEL(radioID[_i]);
        if(_b){
            if(_b.value==method){
                _b.checked=true;
            }
        }
    }

    
    function resizeIframe(iframeID) {
        if(self==parent)
            return false;
        else if(document.getElementById&&document.all){
            var FramePageHeight = document.body.scrollHeight + 10;
            parent.document.getElementById(iframeID).style.height=FramePageHeight;
        }
   }
   //resizeIframe('ifrmCommentSubmit');
</script>

    
</body></html>

<%
Dim txtFullname
Dim txtEmail
Dim txtTitle
Dim txtBody
Dim chkShowEmail
Dim txtCaptcha

Dim cmdSave
Dim mValidation


Public Function Page_Init()
	Set txtFullname	= New_ServerTextBoxEX("txtFullname",20,20)
	Set txtEmail	= New_ServerTextBoxEX("txtEmail",20,20)
	Set txtTitle	= New_ServerTextBoxEX("txtTitle",20,20)
	Set txtBody	= New_ServerTextBoxEX("txtBody",20,20)
	Set txtCaptcha	= New_ServerTextBoxEX("txtCaptcha",20,20)
	Set  chkShowEmail	= New_ServerCheckBox("chkShowEmail")
	
	Set cmdSave = New_ServerLinkButton("cmdSave")
	Set mValidation = New ServerValidationSummary
End Function


Public Function Page_Controls_Init()	

	txtBody.Mode=3
	txtBody.Rows = 3
	txtBody.Cols = 30
	
	cmdSave.Text = "Gửi bài bình luận"
End Function


Public Function cmdSave_OnClick()
	
	Call Validate()
	If Not mValidation.IsValid Then
	
		Exit Function
	End If

	Dim sSQL
	Dim rs
	
	if TestCaptcha("ASPCAPTCHA", txtCaptcha.Text) then
			'Response.Write("<b style=""color:#00CC33"">The code you enter verified.</b>")
			'save data
			
		sSQL = "SELECT * FROM comment Where id=0"
		
		
		Set rs = DBLayer.GetRecordSet(sSQL)
		
		
		If rs.RecordCount = 0 Then
			rs.AddNew
		End If
		
		rs("contentid").Value	= Request.QueryString("id")
		rs("fullname").Value    = txtFullname.Text	
		rs("title").Value		= txtTitle.Text
		rs("email").Value	= txtEmail.Text
		rs("body").Value	= txtBody.Text
		rs("ShowEmail").Value = chkShowEmail.Checked
		rs("createtime").Value = Now()
		
	
		rs("status").Value = 0 'created
		rs("isdeleted").Value = False
			
	
		DBLayer.UpdateRecordSet rs

		If mValidation.IsValid Then
			Response.Redirect "AddComment.asp?id=" & Request.QueryString("id") & "&msg=Bạn đã gửi thành công"
		End If
			
	else
		Response.Write("<b style=""color:#FF0000"">You entered the wrong code.</b>")
		exit function
	end if
End function



Public Function Validate()
		
		'You could use several approaches to validation. I normaly use this approach and modify the control output as appropriate
	
		
		mValidation.Validate 	txtTitle,"Title", VALIDATION_DATATYPE_STRING, True , ""
		mValidation.Validate 	txtFullname,"Fullname", VALIDATION_DATATYPE_STRING, True , ""
		mValidation.Validate 	txtEmail,"Email", VALIDATION_DATATYPE_STRING, True , ""
		mValidation.Validate 	txtBody,"Body", VALIDATION_DATATYPE_STRING, True , ""
		mValidation.Validate 	txtCaptcha,"Captcha", VALIDATION_DATATYPE_STRING, True , ""
End Function


function TestCaptcha(byval valSession, byval valCaptcha)
	dim tmpSession
	valSession = Trim(valSession)
	valCaptcha = Trim(valCaptcha)
	if (valSession = vbNullString) or (valCaptcha = vbNullString) then
		TestCaptcha = false
	else
		tmpSession = valSession
		valSession = Trim(Session(valSession))
		Session(tmpSession) = vbNullString
		if valSession = vbNullString then
			TestCaptcha = false
		else
			valCaptcha = Replace(valCaptcha,"i","I")
			if StrComp(valSession,valCaptcha,1) = 0 then
				TestCaptcha = true
			else
				TestCaptcha = false
			end if
		end if		
	end if
end function


%>